#ifndef _VC10EA_

#include <math.h> 


#include "cTypes.h"
#include "BitLine.h"

static const unsigned int Lo = 0xFFFF;

#endif //ndef _VC10EA_



#define  GetCNL_Mant(N, L) ( CNL_Mant[(N)][(L)] )
#define  GetCNL_Exp(N, L)  ( CNL_Exp[(N)][(L)] )

BYTE			CNL_Exp[UBoundCNL+1][UBoundCNL+1]; 
unsigned int	CNL_Mant[UBoundCNL+1][UBoundCNL+1]; 
int			Cnt1_In_Byte[256];



/*********************************************************************************


							Init_CNL_Table

*********************************************************************************/


void A_add_B(unsigned int *AB_Mant, BYTE *AB_Exp, unsigned int A_Mant, BYTE A_Exp, unsigned int B_Mant, BYTE B_Exp)
{
	unsigned int  LAB, HAB, PAB;

	if (A_Exp < B_Exp) {
		A_add_B(AB_Mant, AB_Exp, B_Mant, B_Exp, A_Mant, A_Exp);
	} else {
		HAB = B_Mant>>(A_Exp - B_Exp);
		LAB = (HAB & Lo) + (A_Mant & Lo);
		HAB = (LAB>>16) + (A_Mant>>16) + (HAB>>16);
		LAB &= Lo;
		PAB = A_Exp;
		
		if (HAB > Lo) {
			LAB = (LAB>>1) | ((HAB & 1) <<15);
			HAB = HAB >> 1;
			PAB+=1;
		}
    
		*AB_Mant = (HAB<<16) | LAB;
		*AB_Exp  = PAB;



	}
}

void Init_CNL_Table()
{
	int L, N, i, j;
	unsigned int M1, M2;
	BYTE E1, E2;

	
	CNL_Mant[0][1] = 1; CNL_Exp[0][1] = 0;
	CNL_Mant[1][1] = 1; CNL_Exp[1][1] = 0;
	
	for (L = 2; L<=UBoundCNL; L++) {
		CNL_Mant[0][L] = 1;		CNL_Exp[0][L] = 0;
		CNL_Mant[1][L] = L;		CNL_Exp[1][L] = 0;
		
		for (N = 2; N<= (L / 2); N++) {

			M1 = GetCNL_Mant(N, L - 1);     E1 = GetCNL_Exp(N, L - 1);
			M2 = GetCNL_Mant(N - 1, L - 1); E2 = GetCNL_Exp(N - 1, L - 1);
			
			A_add_B(&CNL_Mant[N][L], &CNL_Exp[N][L], M1, E1, M2, E2 );
			
			if ( (CNL_Exp[N][L] > CNL_Exp[N][L - 1]) || (CNL_Exp[N][L - 1] > CNL_Exp[N - 1][L - 1]) ) 
				A_add_B(&CNL_Mant[N][L], &CNL_Exp[N][L], CNL_Mant[N][L], CNL_Exp[N][L], 1, CNL_Exp[N][L]);
			
		}

		for (N = (L / 2)+1; N<=L; N++) {
			CNL_Mant[N][L] = CNL_Mant[L-N][L];	CNL_Exp[N][L] = CNL_Exp[L-N][L];
		}
	}
  
	for (i = 0; i<256; i++) {
		Cnt1_In_Byte[i]=0;
		j = i;
		while (j) { Cnt1_In_Byte[i]+=j&1; j>>=1; }
	}
}


/*********************************************************************************


							L I B

*********************************************************************************/
INLINE void Invert(int Io, BYTE *BL, int L)
{
	while ( ((Io & 7)!=0) && (L>0)) { XorBit(BL, Io); Io++; L--; }
	Io>>=3;	
	while (L>=8) { BL[Io] ^= 0xFF; L-=8; Io++;}
	BL[Io] ^= 0xFF >> (8-L);
}

INLINE void Clean(int Io, BYTE *BL, int L)
{
	while ( ((Io & 7)!=0) && (L>0)) { ClrBit(BL, Io); Io++; L--; }
	Io>>=3;
	while (L>=8) { BL[Io] = 0; L-=8; Io++;}
	BL[Io] &= 0xFF << L;
}

INLINE void Fill(int Io, BYTE *BL, int L)
{
	while ( ((Io & 7)!=0) && (L>0)) { SetBit(BL, Io); Io++; L--; }
	Io>>=3;	
	while (L>=8) { BL[Io] = 0xFF; L-=8; Io++;}
	BL[Io] |= 0xFF >> (8-L);
}

int GetCounter1(int Io, BYTE *BL, int L)
{
	int C1=0;
	while ( ((Io & 7)!=0) && (L>0)) { C1+=GetBit(BL, Io); Io++; L--; }
	Io>>=3;	
	while (L>=8) { C1+=Cnt1_In_Byte[BL[Io]]; L-=8; Io++;}
	C1+=Cnt1_In_Byte[BL[Io] & (0xFF >> (8-L))];
	return C1;
}




void PutNumber(int N, int MaxN, BYTE *Pool, int *Start)		// Max bits for Number =32-7
{
	int M, S;
#ifndef	_TI_	
	int *P;
#else
	BYTE *P;
	unsigned int DW; 
#endif
	
	if (MaxN == 0) return;

	S = *Start & 7;
	
#ifndef	_TI_	
	P = (int *) (Pool+(*Start>>3));
	*P = *P & (0xFF >> (8-S)) | (N<<S);
#else
	P = Pool+(*Start>>3);
	DW = ((unsigned int) *P) & (0xFF >> (8-S)) | (N<<S);
	*P = DW;
	P[1] = DW>>8;
	P[2] = DW>>16;
	P[3] = DW>>24;
#endif	
	
	
	M = MaxN; S =0; while (M!=1) { M>>=1; S++; }
	M = 1<<S;
	if ( (N & (M - 1)) <= (MaxN ^ M) ) *Start += S+1; else *Start+=S; 
}


int GetNumber(int MaxN, BYTE *Pool, int *Start)
{
	int M, S, N;
#ifndef	_TI_	
	int *P;
#else
	BYTE *P;
#endif
	
	if (MaxN == 0) return 0;

#ifndef	_TI_	
	P = (int *) (Pool+(*Start>>3));
	N = *P>>(*Start & 7);
#else
	P = Pool+(*Start>>3);
	N = (unsigned int) *P + (((unsigned int) P[1])<<8) + (((unsigned int) P[2])<<16) 
	    + (((unsigned int) P[3])<<24);
	N = N>>(*Start & 7);
#endif

	
	M = MaxN; S =0; while (M!=1) { M>>=1; S++; }
	M = 1<<S; N &= M+M-1;
	if ( (N & (M - 1)) <= (MaxN ^ M) ) *Start += S+1; else {*Start+=S; N &= M-1;}
	return N;
}


INLINE int PkLen_Number(int N, int MaxN)
{
	int M, S; 
	
	if (MaxN == 0) return 0;

	M = MaxN; S =0; while (M!=1) { M>>=1; S++; }
	M = 1<<S; 
	if ( (N & (M - 1)) <= (MaxN ^ M) ) return S+1; else return S;
}


int BitLine_PackLength(int N, int L)
{
	int i, BLL;
  
	if (L == 0) return 0;

	if (L>UBoundCNL) return (BitLine_PackLength(N*UBoundCNL/L, UBoundCNL) * L) / UBoundCNL;

	//if (N > (L / 2)) N = L - N;
  
	if (CNL_Exp[N][L] == 0) { 
		i = CNL_Mant[N][L] - 1;
		if (i < 0) return 32;
		BLL = 0;
		while (i) { i >>= 1; BLL++; }
		return BLL;
	} else return (int) 32 + CNL_Exp[N][L];
}

void PutNumber_Tab(int N, int Tab, BYTE *Pool, int *Start)		
{
	int M, S;
#ifndef	_TI_	
	int *P; 
#else
	unsigned int DW;
	BYTE *P;
#endif		
	
	M = 1<<Tab;
	while (1) {
				
		S = *Start & 7;
#ifndef	_TI_	
		P = (int *) (Pool+(*Start>>3));
		*P = *P & (0xFF >> (8-S)) | ((N|M)<<S);
#else
		P = Pool+(*Start>>3);
		DW = ((unsigned int) *P) & (0xFF >> (8-S)) | ((N|M)<<S); 
		*P = DW;
		P[1] = DW>>8;
		P[2] = DW>>16;
		P[3] = DW>>24;
#endif		
		*Start += Tab+1;
		N>>=Tab;
		if (N==0) { ClrBit(Pool, *Start-1); break; }
	}			
}

int GetNumber_Tab(int Tab, BYTE *Pool, int *Start)
{
	int M, S, N, V, VS; 
#ifndef	_TI_	
	int *P; 
#else
	BYTE *P;
#endif		

	N = 0;
	M = 1<<Tab; VS = 0;
	while (1) {
				
		S = *Start & 7;

#ifndef	_TI_	
		P = (int *) (Pool+(*Start>>3));
		V = *P >> S; 
#else
		P = Pool+(*Start>>3);
		V = (unsigned int) *P + (((unsigned int) P[1])<<8) + (((unsigned int) P[2])<<16) 
	    + (((unsigned int) P[3])<<24);
		V >>= S; 
#endif		

		*Start += Tab+1;
		N |= (V & (M-1)) << VS;  VS+=Tab; 
		if (!(V & M)) break; 
	}
	return N;
}


/*********************************************************************************


							Pack_Bit_Line

*********************************************************************************/

void Pack_Bit_Line(int Io, BYTE *BL, BYTE *Pool, int *Start, int N, int L)
{
	int i, P, Cnt1, FirstL, BLPkL;
	unsigned int PkStart, B16, Shift, CM, CE, Mant;

#ifndef _TI_	
	unsigned int *p32;
	WORD *p16;
#else	
	BYTE *p8;
#endif	
	
  
	if ((L == 0) || (N == 0) || (L == N)) return;
     
	if (L > UBoundCNL) {
		if (L < (UBoundCNL * 2)) FirstL = L >>1; else FirstL = UBoundCNL;
		Cnt1 = GetCounter1(Io, BL, FirstL);
		if (N < FirstL) PutNumber(Cnt1, N, Pool, Start); else PutNumber(Cnt1, FirstL, Pool, Start);
		Pack_Bit_Line(Io, BL, Pool, Start, Cnt1, FirstL);
		Pack_Bit_Line(Io + FirstL, BL, Pool, Start, N - Cnt1, L - FirstL);
		return;
	}
	
    if (N > (L >>1)) {
		Invert(Io, BL, L);
		Pack_Bit_Line(Io, BL, Pool, Start, L - N, L);
		Invert(Io, BL, L);
		return;
	}
   
	PkStart = *Start;
	BLPkL = BitLine_PackLength(N, L);
	*Start += BLPkL;
	Clean(PkStart, Pool, BLPkL+32);

	P = 0;
	for (i = 1; i<=N; i++) {
		while (!GetBit(BL, Io + P)) P++; 
		if ((L - P) == (N - i + 1)) break;
        
		CM = GetCNL_Mant( N - i + 1, L - P - 1); CE = GetCNL_Exp( N - i + 1, L - P - 1);
		
		Shift = PkStart+CE; 
#ifndef	_TI_
		p16 = (WORD *) (Pool+(Shift>>3));
		Shift &=7; 
		B16 = ((CM & Lo) << Shift) + *p16;
		*p16++ = B16;
#else
		p8 = Pool+(Shift>>3);
		Shift &=7; 
		B16 = ((CM & Lo) << Shift) + (unsigned int) *p8 + (((unsigned int) p8[1])<<8) ;
		*p8++ = B16;
		*p8++ = B16>>8;
#endif		
		
		
		B16 = (B16>>16) + ((CM >> 16) << Shift);
		while (B16)	{
#ifndef	_TI_
			B16 += *p16; 
			*p16++ = B16;
#else
			B16 += (unsigned int) *p8 + (((unsigned int) p8[1])<<8);
			*p8++ = B16;
			*p8++ = B16>>8;			
#endif				
			B16>>=16;
		}

		P++;
	}


	// HIGH BIT TEST:
	CM = GetCNL_Mant(N, L); CE = GetCNL_Exp(N, L);
#ifndef	_TI_
	if (CE>0) {
		P = *Start-32;
		p32 = (unsigned int *) (Pool+(P>>3));
	    P &=7; 
		if (P) Mant = (*p32 >> P) | (p32[1] << (32-P)); else  Mant = *p32; 

	} else {
		P = *Start - BLPkL; 
		p32 = (unsigned int *) (Pool+(P>>3));
	    P &=7; 
		if (P) Mant = (*p32 >> P) | (p32[1] << (32-P)); else  Mant = *p32; 

		CM--;
		while ((CM>>31)==0) { CM<<=1; Mant<<=1; }
	}
#else
	if (CE>0) {
		P = *Start-32;
		p8 = Pool+(P>>3);
	    P &=7; 
	    Mant = ((unsigned int) (*p8)) + (((unsigned int) p8[1])<<8) + 
	           (((unsigned int) p8[2])<<16) + (((unsigned int) p8[3])<<24);
		if (P) Mant = (Mant >> P) | (((unsigned int) p8[4]) << (32-P)); 

	} else {
		P = *Start - BLPkL; 
		p8 = Pool+(P>>3);
	    P &=7; 
	    Mant = (unsigned int) *p8 + (((unsigned int) p8[1])<<8) + 
	          (((unsigned int) p8[2])<<16) + (((unsigned int) p8[3])<<24);
		if (P) Mant = (Mant >> P) | (((unsigned int) p8[4]) << (32-P)); 

		CM--;
		while ((CM>>31)==0) { CM<<=1; Mant<<=1; }
	}

#endif	
	

	Mant |= ((unsigned int) 1<<31);
	if (Mant>CM) *Start-=1; // Del High Bit

}

/*********************************************************************************


							Unpack_Bit_Line

*********************************************************************************/

void Unpack_Bit_Line(int Io, BYTE * RESTRICT BL, BYTE *RESTRICT Pool, int *RESTRICT Start, int N, int L)
{
	int L_P_1, Cnt1, FirstL, PkSZ, P, Shift;
	unsigned int PkStart, Mnt, NBits, V, V1, CM, CE;
#ifndef _TI_	
	unsigned int *p32;
#else	
	BYTE *p8;
#endif	
	
   
	if (L == 0) return;

	if (N == 0) { Clean(Io, BL, L); return; }

	if (N == L) { Fill(Io, BL, L); return; }
   
   
	if (L > UBoundCNL) { 
		if (L < (UBoundCNL * 2)) FirstL = L >>1; else FirstL = UBoundCNL;
		if (N < FirstL) Cnt1 = GetNumber(N, Pool, Start); else Cnt1 = GetNumber(FirstL, Pool, Start);
		Unpack_Bit_Line(Io, BL, Pool, Start, Cnt1, FirstL);
		Unpack_Bit_Line(Io + FirstL, BL, Pool, Start, N - Cnt1, L - FirstL);
		return;
	}
  
#ifdef _MMX_
		INTEL_Unpack_Bit_Line_255(Io, BL, Pool, Start, N, L); 
		return;
#endif


    if (N > (L >>1)) {
		Unpack_Bit_Line(Io, BL, Pool, Start, L - N, L);
		Invert(Io, BL, L);
		return;
	}
  

	Clean(Io, BL, L);

	PkSZ = BitLine_PackLength(N, L);
	PkStart = *Start;
	*Start += PkSZ;


	// HIGH BIT TEST:
	CM = GetCNL_Mant(N, L); CE = GetCNL_Exp(N, L);
#ifndef	_TI_
	if (CE>0) {
		P = *Start-32;
		p32 = (unsigned int *) (Pool+(P>>3));
	    P &=7; 
		if (P) Mnt = (*p32 >> P) | (p32[1] << (32-P)); else  Mnt = *p32; 

	} else {
		P = *Start - PkSZ; 
		p32 = (unsigned int *) (Pool+(P>>3));
	    P &=7; 
		if (P) Mnt = (*p32 >> P) | (p32[1] << (32-P)); else  Mnt = *p32; 

		CM--;
		while ((CM>>31)==0) { CM<<=1; Mnt<<=1; }
	}
#else
	if (CE>0) {
		P = *Start-32;
		p8 = Pool+(P>>3);
	    P &=7; 
	    Mnt = (unsigned int) *p8 + (((unsigned int) p8[1])<<8) + 
	          (((unsigned int) p8[2])<<16) + (((unsigned int) p8[3])<<24);
		if (P) Mnt = (Mnt >> P) | (((unsigned int) p8[4]) << (32-P)); 

	} else {
		P = *Start - PkSZ; 
		p8 = Pool+(P>>3);
	    P &=7; 
	    Mnt = (unsigned int) *p8 + (((unsigned int) p8[1])<<8) + 
	          (((unsigned int) p8[2])<<16) + (((unsigned int) p8[3])<<24);
		if (P) Mnt = (Mnt >> P) | (((unsigned int) p8[4]) << (32-P)); 

		CM--;
		while ((CM>>31)==0) { CM<<=1; Mnt<<=1; }
	}
	
#endif	

	Mnt |= ((unsigned int) 1<<31);
	if (Mnt>CM) { *Start-=1; PkSZ--; } // Del High Bit


	while (!GetBit(Pool, PkStart+PkSZ-1)) if (!(--PkSZ)) break;
	
	if (PkSZ<=0) { Fill(Io+L-N, BL, N); return; }

	PkSZ -=32;


	Shift = PkStart+PkSZ; 
#ifndef	_TI_
	if (Shift<0) {
		p32 = (unsigned int *) Pool;
		Mnt = *p32<<(-Shift);
	} else {
		p32 = (unsigned int *) (Pool+(Shift>>3));
		Shift &=7; 
		if (Shift) Mnt = (*p32 >> Shift) | (p32[1] << (32-Shift)); else  Mnt = *p32; 
	}
#else
	if (Shift<0) {
		p8 = Pool;
	    Mnt = (unsigned int) *p8 + (((unsigned int) p8[1])<<8) + 
	          (((unsigned int) p8[2])<<16) + (((unsigned int) p8[3])<<24);
		Mnt <<=-Shift;
	} else {
		p8 = Pool+(Shift>>3);
		Shift &=7; 
	    Mnt = (unsigned int) *p8 + (((unsigned int) p8[1])<<8) + 
	          (((unsigned int) p8[2])<<16) + (((unsigned int) p8[3])<<24);
		if (Shift) Mnt = (Mnt >> Shift) | (((unsigned int)p8[4]) << (32-Shift));  
	}
#endif	

	L_P_1 = L-1; 
	while (PkSZ>0) {



		CE = GetCNL_Exp(N , L_P_1);
		while (CE>PkSZ) { L_P_1--; CE = GetCNL_Exp(N , L_P_1); }
		CM = GetCNL_Mant(N , L_P_1);

		while ((CE==PkSZ) && (CM>Mnt)) { L_P_1--; CE = GetCNL_Exp(N , L_P_1); CM = GetCNL_Mant(N , L_P_1); }

		if (CE==PkSZ) {
			Mnt-=CM;
		} else {
			

			NBits = PkSZ-CE;
			Mnt -= CM>>NBits; 
			Shift = PkStart+PkSZ-NBits; 
#ifndef	_TI_
			p32 = (unsigned int *) (Pool+(Shift>>3));
			Shift &=7;
			V = *p32;
			*p32 -= (CM & ((1<<NBits)-1)) << Shift; 
			if ((*p32 ^ V) >> (Shift + NBits)) Mnt--;
#else
			p8 = Pool+(Shift>>3);
			Shift &=7;
	    	V = (unsigned int) *p8 + (((unsigned int) p8[1])<<8) + 
	          (((unsigned int) p8[2])<<16) + (((unsigned int) p8[3])<<24);
			V1 = V - ((CM & ((1<<NBits)-1)) << Shift);
			*p8 = V1;
			p8[1] = V1>>8; 
			p8[2] = V1>>16; 
			p8[3] = V1>>24; 
			if ((V1 ^ V) >> (Shift + NBits)) Mnt--;

#endif			
		}

		P = Io - L_P_1 + L - 1; SetBit(BL,P); N--; L_P_1--; 
		
		while ((PkSZ>0) && (!(Mnt >> 31))) { PkSZ--; P = PkStart+PkSZ; Mnt = (Mnt<<1) + GetBit(Pool, P); }
	}
	
	Mnt >>= -PkSZ;

	while (Mnt) {
		CE = GetCNL_Exp(N , L_P_1);
		while (CE>0) { L_P_1--; CE = GetCNL_Exp(N , L_P_1); }
		CM = GetCNL_Mant(N , L_P_1);

		while (CM>Mnt) { L_P_1--; CM = GetCNL_Mant(N , L_P_1); }

		Mnt-=CM;
		P = Io - L_P_1 + L - 1; SetBit(BL,P); N--; L_P_1--; 
	}
	if (N>0) Fill(Io+L-N, BL, N);	

}

/*********************************************************************************

						PkLen_IncDensity_BitLine
							

*********************************************************************************/
INLINE int NumNBits(unsigned int Num)
{
#ifdef	_MMX_
	__asm	{
			BSR	EAX,[Num]
			INC	EAX
	}
#else
		return PkLen_Number(0,Num);
#endif

}

int PkLen_IncDensity_BitLine(int Io, BYTE *BL, int Cnt1, int L)
{
	int HC1, H, PL, PL1, hC, E;

  
  
	if ((L == 0) || (Cnt1 == 0) || (Cnt1 == L)) return 0;
  
	if ((Cnt1 == 1) || (Cnt1 == (L-1)))  return NumNBits(L-1);
	
  
	H = L >>1;
	HC1 = GetCounter1(Io, BL, H);


	
	if (Cnt1 > H) {
		hC = (L-Cnt1)>>1; 
		E = hC>>1;
		if (abs(H-HC1-hC)< E) return 1+ BitLine_PackLength(Cnt1, L);

	} else {
		hC = Cnt1>>1; 
		E = hC>>1;
		if (abs(HC1-hC)< E) return 1+ BitLine_PackLength(Cnt1, L);
	}
	
  
	PL = NumNBits(Min_(Cnt1,L-Cnt1)) + PkLen_IncDensity_BitLine(Io, BL, HC1, H) + 
											  PkLen_IncDensity_BitLine(Io + H, BL, Cnt1 - HC1, L - H);
	PL1 = BitLine_PackLength(Cnt1, L);
	
	return 1+Min_(PL,PL1); 
}

/*********************************************************************************

						Pack_IncDensity_BitLine
							

*********************************************************************************/

void Pack_IncDensity_BitLine(int Io, BYTE *BL, BYTE *Pool, int *Start, int Cnt1, int L)
{
	int i, HC1, H;
  
  
	if ((L == 0) || (Cnt1 == 0) || (Cnt1 == L)) return;
  
	if (Cnt1 > (L / 2)) {
		Invert(Io, BL, L);
		Pack_IncDensity_BitLine(Io, BL, Pool, Start, L-Cnt1, L);
		return;
	}

	if (Cnt1 == 1)  {
		i = Io;
		while (!GetBit(BL, i)) i++;
		PutNumber(i-Io, L - 1, Pool, Start);
		return;
	}
  
	H = L >>1;
	HC1 = GetCounter1(Io, BL, H);
  
	if ((PkLen_Number(HC1, Cnt1) + PkLen_IncDensity_BitLine(Io, BL, HC1, H) + 
		PkLen_IncDensity_BitLine(Io + H, BL, Cnt1 - HC1, L - H)) >= BitLine_PackLength(Cnt1, L)) {
		
		PutNumber(0, 1, Pool, Start);
		Pack_Bit_Line(Io, BL, Pool, Start, Cnt1, L);
	} else {
  
		PutNumber(1, 1, Pool, Start);
		PutNumber(HC1, Cnt1, Pool, Start);
		Pack_IncDensity_BitLine(Io, BL, Pool, Start, HC1, H);
		Pack_IncDensity_BitLine(Io + H, BL, Pool, Start, Cnt1 - HC1, L - H);
	}
  
}

/*********************************************************************************

						Unpack_IncDensity_BitLine
							

*********************************************************************************/

void Unpack_IncDensity_BitLine(int Io, BYTE *BL, BYTE *Pool, int *Start, int Cnt1, int L)
{
	int i, HC1, H;
  
	if (L == 0) return;

	if (Cnt1 == 0) { Clean(Io, BL, L); return; }

	if (Cnt1 == L) { Fill(Io, BL, L); return; }
   
  
	if (Cnt1 > (L / 2)) {
		Unpack_IncDensity_BitLine(Io, BL, Pool, Start, L-Cnt1, L);
		Invert(Io, BL, L);
		return;
	}

	if (Cnt1 == 1)  {
		Clean(Io, BL, L);
		i = Io+GetNumber(L - 1, Pool, Start);
		SetBit(BL, i);
		return;
	}
  
  
	if (GetNumber(1, Pool, Start)==0) {
		Unpack_Bit_Line(Io, BL, Pool, Start, Cnt1, L);
	} else {
		H = L >>1;
		HC1 = GetNumber(Cnt1, Pool, Start);
		
		Unpack_IncDensity_BitLine(Io, BL, Pool, Start, HC1, H);
		Unpack_IncDensity_BitLine(Io + H, BL, Pool, Start, Cnt1 - HC1, L - H);
	}
  
} 
